import os
from loguru import logger

# 获取当前文件所在目录的根目录路径
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# 拼接日志文件的完整路径
log_file_path = os.path.join(root_dir, "logs", "{time:YYYY-MM-DD}.logs")

logger.add(log_file_path, rotation="00:00", encoding="utf-8")
# 异常日志
logger.add(
    os.path.join(root_dir, "logs", "exceptions.logs"),
    rotation="00:00",
    encoding="utf-8",
    level="ERROR",
    backtrace=True,
    diagnose=True
)